package com.authsphere.plugin.base;

import com.authsphere.common.entity.PluginData;
import com.authsphere.plugin.api.AuthSphereBeforePlugin;
import com.authsphere.plugin.api.AuthSphereBeforePluginChain;
import com.authsphere.plugin.api.WebExchange;
import com.authsphere.plugin.base.cache.BaseDataCache;

/**
 * @program: AuthSphere
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/25 11:25
 **/
public abstract class AbstractAuthSphereBeforePlugin implements AuthSphereBeforePlugin {

    @Override
    public void execute(WebExchange exchange, AuthSphereBeforePluginChain chain) {
        PluginData pluginData = BaseDataCache.getInstance().obtainPluginData(name());
//        if (pluginData == null || !pluginData.getEnabled()) {
//            chain.execute(exchange);
//            return;
//        }
        doExecute(exchange, chain, pluginData);
    }

    protected abstract void doExecute(WebExchange context, AuthSphereBeforePluginChain chain, PluginData pluginData);
}
